#include <bits/stdc++.h>

using namespace std;
#define int long long


void solve()
{
    auto check = [&](int k)
    {
        int j = sqrtl((int64_t)k * (k + 1) / 2);
        return ((int64_t)j * j != (int64_t)k * (k + 1) / 2);
    };
    int n; cin >> n;
    if(!check(n))
    {
        cout << -1 << endl;
        return;
    }
    vector<int>ans(n + 1);
    for(int i = 1;i <= n;i ++)
    {
        ans[i] = i;
    }
    int j = 0;
    for(int i = 1;i <= n;i ++)
    {
        while(j * j < i * (i + 1)/ 2) j ++;
        if(j * j == i * (i + 1) / 2)
        {
            swap(ans[i] , ans[i + 1]);
        }
        cout << ans[i] << " ";
    }
    cout << endl;
}
signed main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}